#include <stdio.h>
#include "json.h"

#define CRTDBG_MAP_ALLOC  

char buf[] = "\
{\
	\"employees\": [\
	{\
		\"firstName\": \"Bill\",\
			\"lastName\" : \"Gates\"\
	}\
	],\
	\"abc\":\"test\",\
	\"trrt\":123.560450\
}\
";

JSON* root,*fmt;

char outbuf[300];
int len = 0;
int main(void)
{

		JSON* obj = JSON_Parse(buf);
		if (obj != NULL)
		{
			len = JSON_Print(obj, outbuf);
			JSON_Delete(obj);		
		}

		root = JSON_CreateObject();
		JSON_AddItemToObject(root, "name", JSON_CreateString("Jack (\"Bee\") Nimble"));
		JSON_AddItemToObject(root, "format", fmt = JSON_CreateObject());
		JSON_AddStringToObject(fmt, "type", "rect");
		JSON_AddNumberToObject(fmt, "width", 1920);
		JSON_AddNumberToObject(fmt, "height", 1080);
		JSON_AddBoolToObject(fmt, "interlace",1);
		JSON_AddNumberToObject(fmt, "frame rate", 24);
		memset(outbuf,0,sizeof(outbuf));
		JSON_Print(root, outbuf);
		printf("%s\r\n",outbuf);
		JSON_Delete(root);

		_CrtDumpMemoryLeaks();

	return 0;
}

